package cn.com.klun.tjy.other.jvm;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import static org.apache.xpath.XPath.SELECT;
import static org.springframework.http.HttpHeaders.FROM;

public class VectorTest {

    /**
     * 问题1：final修饰的方法
     * 问题2：阅读两种类型的java源码 AtomicInteger.incrementAndGet()  CAS操作
     */
    private static Vector<Integer> vector = new Vector<>();

    public static void main(String[] args) {
        while (true){
            for (int i = 0; i < 10; i++) {
                vector.add(i);
            }
            Thread removeThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i = 0; i < vector.size(); i++) {
                        vector.remove(i);
                    }
                }
            });
            Thread printThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i = 0; i < vector.size(); i++) {
                        System.out.print(vector.get(i));
                    }
                }
            });
            removeThread.start();
            printThread.start();
            while (Thread.activeCount()>20);

        }

    }
    public void testSql(){
        // SELECT * FROM java.lang.String;
        // SELECT toString(s),s.count,s.value FROM java.lang.String s;
        AtomicInteger race = new AtomicInteger();
        race.incrementAndGet();
        StringBuffer sb = new StringBuffer();
    }

}
